package it.uniba.di.mas.jpnde.core;

import java.util.Arrays;

import jade.util.leap.ArrayList;
import jade.util.leap.List;

public class Transition extends PNObject 
	implements IDeliverable{

	private static final long serialVersionUID = 1L;
	public static final String XMLNODE="transition";
	public static final String XMLCONTAINER_NODE="jpncontainer";
	public static final String XMLIMPLCLASS_NODE="jpnimplClass";
	
	private String implClass="";
	private String container="";
	
	private List preset=new ArrayList();
	private List postset=new ArrayList();
	
	private String agentId="";
	private String managerId="";
	private Token returnToken=null;
	
	public String getImplClass() {
		return implClass;
	}
	public void setImplClass(String implClass) {
		this.implClass = implClass;
	}
	
	public String getContainer() {
		return container;
	}
	public void setContainer(String container) {
		this.container = container;
	}
	public List getPreset() {
		return preset;
	}
	public List getSortedPreset(){
		Arc[] arcs=new Arc[preset.size()];
		for(int i=0;i<preset.size();i++)
			arcs[i]=(Arc)preset.get(i);
		Arrays.sort(arcs);
		ArrayList ret=new ArrayList();
		for(int i=arcs.length-1;i>=0;i--)
			ret.add(arcs[i]);
		return ret;
	}
	public void setPreset(List preset) {
		this.preset = preset;
	}
	public List getPostset() {
		return postset;
	}
	public void setPostset(List postset) {
		this.postset = postset;
	}
	
	public String getAgentId() {
		return agentId;
	}
	public void setAgentId(String agentId) {
		this.agentId = agentId;
	}
	
	public String getManagerId() {
		return managerId;
	}
	public void setManagerId(String managerId) {
		this.managerId = managerId;
	}
	
	public Token getReturnToken() {
		return returnToken;
	}
	public void setReturnToken(Token token) {
		this.returnToken = token;
	}
	
	@Override
	public String toString() {
		return "Transition [id=" + id + ", name=" + name
				+ ", implClass=" + implClass + ",container=" + container+",postset=" + postset
				+ ", preset=" + preset + "]";
	}
	
}
